package com.societyGames.interceptExercises
{
public class Parser
{
  public static function parse(xml:XML):INumberExpression
  {
    switch (xml.localName())
    {
      case "add":
        return new AddExpression(xml);
      case "constant":
        return new NumberConstantExpression(xml);
      case "divide":
        return new DivideExpression(xml);
      case "functionCall":
        return new FunctionCallExpression(xml);
      case "int":
        return new IntCastExpression(xml);
      case "modulo":
        return new ModuloExpression(xml);
      case "multiply":
        return new MultiplyExpression(xml);
      case "negate":
        return new NegateExpression(xml);
      case "subtract":
        return new SubtractExpression(xml);
    }
    throw new ArgumentError("Unknown expression type: " + xml.localName());
  }
}
}